{{- if or .Values.istio.federation.enabled .Values.istio.multicluster.enabled }}
  {{- if .Values.global.modules.publicDomainTemplate }}
    {{- if eq (include "helm_lib_module_https_mode" .) "Disabled" }}
      {{- fail "HTTPS is mandatory for spiffe endpoint" }}
    {{- end }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: metadata-exporter
  namespace: d8-{{ $.Chart.Name }}
  {{- include "helm_lib_module_labels" (list . (dict "app" "metadata-exporter")) | nindent 2 }}
spec:
  ingressClassName: {{ include "helm_lib_module_ingress_class" . | quote }}
  rules:
  - host: {{ include "helm_lib_module_public_domain" (list . "istio") }}
    http:
      paths:
      - backend:
          service:
            name: metadata-exporter
            port:
              name: http
        path: /metadata/
        pathType: ImplementationSpecific
    {{- if (include "helm_lib_module_https_ingress_tls_enabled" .) }}
  tls:
    - hosts:
        - {{ include "helm_lib_module_public_domain" (list . "istio") }}
      secretName: {{ include "helm_lib_module_https_secret_name" (list . "istio-ingress-tls") }}
    {{- end }}
  {{- end }}
{{- end }}
